
'''
https://leetcode.cn/problems/ransom-note/description/
给你两个字符串：ransomNote 和 magazine ，判断 ransomNote 能不能由 magazine 里面的字符构成。
如果可以，返回 true ；否则返回 false 。magazine 中的每个字符只能在 ransomNote 中使用一次。

示例 1：

输入：ransomNote = "a", magazine = "b"
输出：false
示例 2：

输入：ransomNote = "aa", magazine = "ab"
输出：false
示例 3：

输入：ransomNote = "aa", magazine = "aab"
输出：true

'''

def l383(ransomNote,magazine):
    from collections import defaultdict
    d1 = defaultdict(int)
    for i in ransomNote:
        d1[i] += 1
    for i in magazine:
        d1[i] -= 1
    for i in ransomNote:
        if d1[i] > 0 :return False
    return True
    pass

if __name__ == '__main__':
    print(l383("aa","aab"))

    print(l383("aac","aaab"))
    print(l383("aa","aaab"))
    pass